<template>
  <div class="StorageRate">
    <el-card class="box-card">
      <div slot="header" class="clearfix">
        <span style="line-height: 36px;">库位使用率统计</span>
      </div>
      <s-table
        :table="table"
        @http="tableWatch">
        <el-row>
          <el-col :xs="24" :lg="{span: 4, offset: 0}">
            <el-form-item label="库区名称" prop="kqmc">
              <el-input type="text"
                        class="input"
                        v-model="autoVue_table_kqmc"
                        placeholder="库区名称" spellcheck="false" auto-capitalize="off" auto-complete="off"
                        auto-correct="off"></el-input>
            </el-form-item>
          </el-col>
        </el-row>
        <el-form-item slot="multiSelect" label="多选操作" prop="multiSelect" v-if="table.multiSelect">
          <el-row>
            <el-col :span="8">
              <el-button size="small" type="info" @click="tableExport('')">多选导出</el-button>
            </el-col>
          </el-row>
        </el-form-item>
      </s-table>
    </el-card>
  </div>
</template>

<script>
  import {AutoVue} from '~/plugins/Tools';
  export default AutoVue({
    name: 'journaling_stockCountDaily-FEcarWms',
    head: {
      'title': '库位使用率统计',
      'meta': [
        { 'hid': 'description', 'name': 'description', 'content': '乐速科技平台 库位使用率统计 查看库位使用率统计信息' },
      ],
    },
    data: {
      table: {
        column: [
          { label: '库区名称',
            prop: 'kqmc',
            minWidth: '0px',
            search: true,
          },
          { label: '库位数量',
            prop: 'nums',
            minWidth: '0px',
            search: false,
          },
          { label: '已占用库位',
            prop: 'yzykw',
            minWidth: '0px',
            search: false,
          },
          { label: '未占用库位',
            prop: 'wzykw',
            minWidth: '0px',
            search: false,
          },
        ],
        url: '/wmsReservoir/baseHarvestPage',
        key: 'id',
        tableColumn: 4,
      },
    },
    transition: 'slide-fade',
    methods: {
      tableExport (row) {
        let tableRef = 'table';
        let ids = [];
        if (row) {
          ids.push(row.id);
        } else {
          this[tableRef].multipleSelection.forEach(item => {
            ids.push(item.kqid);
          });
        }
        this.$confirm('您将导出库位使用率报表数据。', '确认导出？', {
          confirmButtonText: '是',
          cancelButtonText: '否',
          type: 'warning',
        })
          .then(async _ => {
            try {
              let option = Object.assign({}, this['autoVue_' + tableRef]);
              await this.p({
                url: '/wmsReservoir/exportWmsproductWarning',
                method: 'post',
                responseType: 'blob',
                data: {
                  ids,
                  ...option,
                },
              });
            } catch (err) {
              console.log(err);
            }
          })
          .catch(_ => {
          });
      },
    },
    mounted: async function () {
      this.tableWatch('table');
    },
  });
</script>

<style scoped lang="scss">
</style>

<style lang="scss">
  .StorageRate{
    width: 88vw;
    float: left;
  }
</style>
